<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <title>ActionController::Helpers::ClassMethods</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <link rel="stylesheet" href="../../../css/reset.css" type="text/css" media="screen" />
<link rel="stylesheet" href="../../../css/main.css" type="text/css" media="screen" />
<link rel="stylesheet" href="../../../css/github.css" type="text/css" media="screen" />
<script src="../../../js/jquery-1.3.2.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../../../js/jquery-effect.js" type="text/javascript" charset="utf-8"></script>
<script src="../../../js/main.js" type="text/javascript" charset="utf-8"></script>
<script src="../../../js/highlight.pack.js" type="text/javascript" charset="utf-8"></script>

</head>

<body>     
    <div class="banner">
        
            <span>Ruby on Rails v4.0.0</span><br />
        
        <h1>
            <span class="type">Module</span> 
            ActionController::Helpers::ClassMethods 
            
        </h1>
        <ul class="files">
            
            <li><a href="../../../files/actionpack/lib/action_controller/metal/helpers_rb.html">actionpack/lib/action_controller/metal/helpers.rb</a></li>
            
        </ul>
    </div>
    <div id="bodyContent">
        <div id="content">
  


  


  
  


  


  
    <!-- Method ref -->
    <div class="sectiontitle">Methods</div>
    <dl class="methods">
      
        <dt>A</dt>
        <dd>
          <ul>
            
              
              <li>
                <a href="ClassMethods.html#method-i-all_helpers_from_path">all_helpers_from_path</a>
              </li>
            
          </ul>
        </dd>
      
        <dt>H</dt>
        <dd>
          <ul>
            
              
              <li>
                <a href="ClassMethods.html#method-i-helper_attr">helper_attr</a>,
              </li>
            
              
              <li>
                <a href="ClassMethods.html#method-i-helpers">helpers</a>
              </li>
            
          </ul>
        </dd>
      
        <dt>M</dt>
        <dd>
          <ul>
            
              
              <li>
                <a href="ClassMethods.html#method-i-modules_for_helpers">modules_for_helpers</a>
              </li>
            
          </ul>
        </dd>
      
    </dl>
  

  



  

    

    

    


    


    <!-- Methods -->
        
      <div class="sectiontitle">Instance Public methods</div>
      
        <div class="method">
          <div class="title method-title" id="method-i-all_helpers_from_path">
            
              <b>all_helpers_from_path</b>(path)
            
            <a href="ClassMethods.html#method-i-all_helpers_from_path" name="method-i-all_helpers_from_path" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-all_helpers_from_path_source')" id="l_method-i-all_helpers_from_path_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/6d10688bbe883b2f0c30d63d3a8ce348d814d986/actionpack/lib/action_controller/metal/helpers.rb#L92" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-all_helpers_from_path_source" class="dyn-source">
                <pre><span class="ruby-comment"># File actionpack/lib/action_controller/metal/helpers.rb, line 92</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">all_helpers_from_path</span>(<span class="ruby-identifier">path</span>)
  <span class="ruby-identifier">helpers</span> = <span class="ruby-constant">Array</span>(<span class="ruby-identifier">path</span>).<span class="ruby-identifier">flat_map</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">_path</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">extract</span> = <span class="ruby-node">/^#{Regexp.quote(_path.to_s)}\/?(.*)_helper.rb$/</span>
    <span class="ruby-identifier">names</span> = <span class="ruby-constant">Dir</span>[<span class="ruby-node">&quot;#{_path}/**/*_helper.rb&quot;</span>].<span class="ruby-identifier">map</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">file</span><span class="ruby-operator">|</span> <span class="ruby-identifier">file</span>.<span class="ruby-identifier">sub</span>(<span class="ruby-identifier">extract</span>, <span class="ruby-string">'\1'</span>) }
    <span class="ruby-identifier">names</span>.<span class="ruby-identifier">sort!</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-identifier">helpers</span>.<span class="ruby-identifier">uniq!</span>
  <span class="ruby-identifier">helpers</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-helper_attr">
            
              <b>helper_attr</b>(*attrs)
            
            <a href="ClassMethods.html#method-i-helper_attr" name="method-i-helper_attr" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              <p>Declares helper accessors for controller attributes. For example, the
following adds new <code>name</code> and <code>name=</code> instance
methods to a controller and makes them available to the view:</p>

<pre>attr_accessor :name
helper_attr :name</pre>

<h4 id="method-i-helper_attr-label-Parameters"><a href="../Parameters.html">Parameters</a></h4>
<ul><li>
<p><code>attrs</code> - Names of attributes to be converted into helpers.</p>
</li></ul>
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-helper_attr_source')" id="l_method-i-helper_attr_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/6d10688bbe883b2f0c30d63d3a8ce348d814d986/actionpack/lib/action_controller/metal/helpers.rb#L70" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-helper_attr_source" class="dyn-source">
                <pre><span class="ruby-comment"># File actionpack/lib/action_controller/metal/helpers.rb, line 70</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">helper_attr</span>(*<span class="ruby-identifier">attrs</span>)
  <span class="ruby-identifier">attrs</span>.<span class="ruby-identifier">flatten</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">attr</span><span class="ruby-operator">|</span> <span class="ruby-identifier">helper_method</span>(<span class="ruby-identifier">attr</span>, <span class="ruby-node">&quot;#{attr}=&quot;</span>) }
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-helpers">
            
              <b>helpers</b>()
            
            <a href="ClassMethods.html#method-i-helpers" name="method-i-helpers" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              <p>Provides a proxy to access helpers methods from outside the view.</p>
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-helpers_source')" id="l_method-i-helpers_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/6d10688bbe883b2f0c30d63d3a8ce348d814d986/actionpack/lib/action_controller/metal/helpers.rb#L75" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-helpers_source" class="dyn-source">
                <pre><span class="ruby-comment"># File actionpack/lib/action_controller/metal/helpers.rb, line 75</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">helpers</span>
  <span class="ruby-ivar">@helper_proxy</span> <span class="ruby-operator">||=</span> <span class="ruby-constant">ActionView</span><span class="ruby-operator">::</span><span class="ruby-constant">Base</span>.<span class="ruby-identifier">new</span>.<span class="ruby-identifier">extend</span>(<span class="ruby-identifier">_helpers</span>)
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-modules_for_helpers">
            
              <b>modules_for_helpers</b>(args)
            
            <a href="ClassMethods.html#method-i-modules_for_helpers" name="method-i-modules_for_helpers" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              <p>Overwrite <a
href="ClassMethods.html#method-i-modules_for_helpers">#modules_for_helpers</a>
to accept :all as argument, which loads all helpers in helpers_path.</p>

<h4 id="method-i-modules_for_helpers-label-Parameters"><a href="../Parameters.html">Parameters</a></h4>
<ul><li>
<p><code>args</code> - A list of helpers</p>
</li></ul>

<h4 id="method-i-modules_for_helpers-label-Returns">Returns</h4>
<ul><li>
<p><code>array</code> - A normalized list of modules for the list of helpers
provided.</p>
</li></ul>
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-modules_for_helpers_source')" id="l_method-i-modules_for_helpers_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/6d10688bbe883b2f0c30d63d3a8ce348d814d986/actionpack/lib/action_controller/metal/helpers.rb#L87" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-modules_for_helpers_source" class="dyn-source">
                <pre><span class="ruby-comment"># File actionpack/lib/action_controller/metal/helpers.rb, line 87</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">modules_for_helpers</span>(<span class="ruby-identifier">args</span>)
  <span class="ruby-identifier">args</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">all_application_helpers</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-value">:all</span>)
  <span class="ruby-keyword">super</span>(<span class="ruby-identifier">args</span>)
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
                    </div>

    </div>
  </body>
</html>    